package com.cryptoneedle.center.source.controller;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.bubbles.engine.common.core.result.Result;
import jakarta.annotation.Resource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>description:  </p>
 *
 * @author CryptoNeedle
 * @date 2025-07-24
 */
@RestController
@RequestMapping("/test")
public class TestController {
    
    @Resource
    private JdbcTemplate jdbcTemplate;
    
    @GetMapping("/master")
    public String master() {
        return jdbcTemplate.queryForObject("SELECT version() AS version", String.class);
    }
    
    @GetMapping("/pg")
    @DS("pg")
    public String pg() {
        return jdbcTemplate.queryForObject("SELECT version() AS version", String.class);
    }
    
    @GetMapping("/doris")
    @DS("doris")
    public String doris() {
        return jdbcTemplate.queryForObject("SELECT version() AS version", String.class);
    }
    
    @GetMapping("/doris/dropCatalog")
    @DS("doris")
    public Result<?> dorisDropCatalog() {
        jdbcTemplate.execute("DROP CATALOG IF EXISTS a");
        return Result.success();
    }
}